/* -*- c -*- */

%{
#include <stdio.h>

static int prints_newline = 1;
%}

%program    "echo"
%usage      "[-n] [string ...]"

%%

-n:
  help "Do not print the trailing newline character",
  action { prints_newline = 0; }

pos string ...:
  action
  {
    int i;

    for (i = 0; i < $nvargs; i++) {
      printf("%s", $string[i]);
      if (prints_newline)
        printf("\n");
      else
        printf(" ");
    }
    if (!prints_newline)
      printf("\n");
  }

%%

int
main(int argc, char **argv)
{
  lg_parse(argc, argv);
  return 0;
}
